package com.chezai.client.global;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.chezai.client.activitys.UpdateAppActivity;
import com.chezai.client.server.UploadGnssService;
import com.chezai.client.utils.AppManager;
import com.orhanobut.logger.Logger;


/**
 * Created by likunyang on 2017/10/17.
 */

public class TerminalBroadcast extends BroadcastReceiver {
    private String TAG = this.getClass().getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (TextUtils.equals(Const.UPDATE_APP, action)) {
            Logger.t(TAG).d("收到升级广播");
            Activity activity = AppManager.getAppManager().currentActivity();
            UpdateAppActivity.openUpdateApp(activity, intent.getStringExtra("url"));

        } else if (TextUtils.equals(Const.RESTART_UPLOAD_GNSS_SERVICE, action)) {
            Logger.t(TAG).i("接收到重启上报位置服务广播");
            Intent a = new Intent(context, UploadGnssService.class);
            context.startService(a);
        }
    }
}
